local Lua__zhengdao = fk.CreateSkill{
  name = "Lua__zhengdao",
  tags = {Skill.Compulsory},
  anim_type = "control",
}

Fk:loadTranslationTable{
  ["Lua__zhengdao"] = "争道",
  [":Lua__zhengdao"] = "锁定技，装备区小于等于你的无法响应你使用的牌。当你受到或造成伤害时，你摸等同于装备区内装备数的牌",
}



-- 使用牌时无法被响应
Lua__zhengdao:addEffect(fk.PreCardUse, {
  can_trigger = function(self, event, target, player, data)
    if target == player and data.card and data.tos[1] and player:hasSkill(Lua__zhengdao.name) then
      local from_equip_count = #player:getCardIds(Player.Equip)
      local to_equip_count = #data.tos[1]:getCardIds(Player.Equip)
      
      -- 如果目标装备区数量小于等于使用者，则无法响应
      return to_equip_count <= from_equip_count
    end
  end,
  
  on_use = function(self, event, target, player, data)
    data.disresponsiveList = table.simpleClone(data.tos)
  end,
})

-- 造成伤害时摸牌
Lua__zhengdao:addEffect(fk.Damage, {
  can_trigger = function(self, event, target, player, data)
    return target == player and player:hasSkill(Lua__zhengdao.name) and #player:getCardIds(Player.Equip) > 0
  end,
  
  on_use = function(self, event, target, player, data)
    local room = player.room
    local equip_count = #player:getCardIds(Player.Equip)

      room:notifySkillInvoked(player, Lua__zhengdao.name, "drawcard")
      player:drawCards(equip_count, Lua__zhengdao.name)

  end,
})

-- 受到伤害时摸牌
Lua__zhengdao:addEffect(fk.Damaged, {
  can_trigger = function(self, event, target, player, data)
    return target == player and player:hasSkill(Lua__zhengdao.name) and #player:getCardIds(Player.Equip) > 0
  end,
  
  on_use = function(self, event, target, player, data)
    local room = player.room
    local equip_count = #player:getCardIds(Player.Equip)
    
      room:notifySkillInvoked(player, Lua__zhengdao.name, "drawcard")
      player:drawCards(equip_count, Lua__zhengdao.name)


  end,
})

return Lua__zhengdao 